from typing import *


class Solution:

    def rob(self, nums: List[int]) -> int:

        def f(l, r):
            if l == len(nums):
                return -1
            s, p = nums[l], 0
            for i in range(l + 1, r):
                s, p = p + nums[i], max(s, p)
            return max(s, p)

        return max(f(1, len(nums)), f(0, len(nums) - 1))
